function im2avi(dirname)

aviobj = avifile('video.avi', 'fps', 30, 'compression', 'None');

graymap = gray(256);

for i = 1:65400
    filename = strcat('./', dirname, '/', int2str(i), '.png');
    if (~exist(filename))
        continue;
    end % if
    str = sprintf('Adding %s to the video', filename); disp(str);
    F = im2frame(imread(filename), graymap);
    aviobj = addframe(aviobj, F);
end % for

aviobj = close(aviobj);